<?php
//Nguyen Van Binh
//binh_mczk@yahoo.com
defined( '_VALID_NVB' ) or die('Direct Access to this location is not allowed.');
$tpl = new TemplatePower("template/contact.htm");
$tpl->prepare();
$tpl->assignGlobal("site_address",$site_address);
$sql="SELECT * FROM menu".$lang." WHERE id_menu=$idmenu";
	$db=$DB->query($sql);
	if($rs=mysql_fetch_array($db)){
		$tpl->assign("namepage",$rs['name']);	
		$tpl->assign("link",$site_address.$lang_dir.process_link($rs['link'],$rs['id_menu']));
	}




//noi dung tren
$sql1="SELECT * FROM static".$lang." WHERE inwhere='incontact' AND active=1";
$db=$DB->query($sql1);
if($rs=mysql_fetch_array($db)){
	$tpl->newBlock("noi_dung");
	$tpl->assign("content",$rs['content']);
}

if($_REQUEST['gone']=="1") {
	if(compile_post("name")!=null &&  compile_post("email")!=null && compile_post("noidung")!=null){
	include_once('lib/class.phpmailer.php');
	include_once('lib/phpmailer.lang-en.php');
	// upload file
	
	
	$name=compile_post('name');
	$email=compile_post('email');
	$address=compile_post('address');
	
	$phone=compile_post('phone');
	$mes=compile_post('noidung');
	
		
	$name=compile_post('name')." date: ".date("d/m/Y",time()+$CONFIG['offset_time']);
	
	$message="
		<table width='600' border='0' cellspacing='0' cellpadding='5'>
	  <tr>
		<td colspan='2' style='text-transform:uppercase'><strong>Thông tin</strong></td>
	  </tr>
	  <tr>
		<td width='109'>Họ và tên</td>
		<td width='471'>$name</td>
	  </tr>
	  <tr>
		<td>Email</td>
		<td>$email</td>
	  </tr>
	
	  <tr>
		<td>Điện thoai</td>
		<td>$phone</td>
	  </tr>
	 
	  <tr>
		<td colspan='2' style='text-transform:uppercase'><strong>Nội dung</strong></td>
	  </tr>
	  <tr>
		<td colspan='2'>$mes</td>
	  </tr>
	</table>";
	$sql='INSERT INTO contact(name,content) VALUES("'.$name.'","'.$message.'")';
	$DB->query($sql);
	$tpl->newBlock("thongbao");
	$tpl->assign("thongbao","Th&#244;ng tin li&#234;n h&#7879; c&#7911;a qu&#253; kh&#225;ch &#273;&#227; &#273;&#432;&#7907;c g&#7917;i &#273;&#7871;n ng&#432;&#7901;i qu&#7843;n tr&#7883; !");
	
	
	
	// Additional headers
	$to=$CONFIG['site_email'];
	$from=$_POST['email'];
	$subject = 'Thông tin liện hệ từ: '.compile_post('name').' '.date("d/m/Y",time()+$CONFIG['offset_time']." vienthammyxuanhuong.com");
	
	sendmail($to,$subject,$message, compile_post('name')." -  Liên hệ từ website");

	}else{
		alert("Bạn chưa nhập đủ thông tin !")	;
	}
}

$tpl->printToScreen();
?>